<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>结构伪类</title>
    <style type="text/css">
        .outer {
            width: 80%;
            border: 1px solid gray;
            margin: 25px auto;
        }

        .outer>* {
            height: 20px;
            border: 1px solid blue;
            margin: 15px;
        }

        .outer p:nth-of-type(2) {
            background: #dedede;
        }

        .outer p:nth-of-type(2n+1) {
            background: #ff0;
        }

        .outer div:nth-of-type(2) {
            background: #9696ff;
        }

        .outer div:nth-last-of-type(2) {
            background: #fba259;
        }

        .outer div:nth-last-of-type(odd) {
            color: red;
            font-size: 20px;
            height: 50px;
            line-height: 50px;
        }

        .outer div:nth-last-of-type(odd)::before {
            content: '俺是div';
        }
    </style>
</head>

<body>

    <div class="outer">
        <div></div>
        <p>第1个段落</p>
        <div></div>
        <p>第2个段落</p>
        <div></div>
        <p>第3个段落</p>
        <div></div>
        <p>第4个段落</p>
        <div></div>
        <p>第5个段落</p>
        <div></div>
        <p>第6个段落</p>
    </div>

</body>

</html>